package service.impl;

import dao.StudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Student;
import service.StudentService;
import util.Page;

import java.util.List;

@Service("StudentService")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    /*@Override
    public Page page(Integer page, Integer pageSize) {
        //1.获取总记录数
        int totalCount = studentDao.count();
        //2.获取分页查询结果列表
        Integer offset = (page - 1) * pageSize;
        List<Student> students = studentDao.findAll3(offset, pageSize);
        Page pageBean = new Page(totalCount, pageSize);
        return pageBean;
    }*/

    @Override
    public List<Student> findAll(Student student, int offset, int pageSize) {
        List<Student> students = studentDao.findAll2(student,offset,pageSize);
        return students;
    }

    @Override
    public int count(Student student) {
        return studentDao.count(student);
    }

    @Override
    public Student findById(int sId) {
        return studentDao.findById(sId);
    }

    @Override
    public boolean login(Student student) {
        if(studentDao.login(student) > 0){
            return true;
        }
        return false;
    }

    @Override
    public int addStudent(Student student) {
        return studentDao.addStudent(student);
    }

    @Override
    public int deleteStudentById(int sId) {
        return studentDao.deleteStudentById(sId);
    }

    @Override
    public int updateStudent(Student student) {
        return studentDao.updateStudent(student);
    }

    @Override
    public List<Student> findAll() {
        /*Student student = new Student();*/
//        return studentDao.findAll();
    return null;
    }
}
